from tortoise import BaseDBAsyncClient


async def upgrade(db: BaseDBAsyncClient) -> str:
    return """
        ALTER TABLE `classes` MODIFY COLUMN `name` VARCHAR(20) NOT NULL  COMMENT '班级名称';
        ALTER TABLE `course` ADD `teacher_id` INT NOT NULL;
        ALTER TABLE `course` MODIFY COLUMN `name` VARCHAR(20) NOT NULL  COMMENT '课程名称';
        ALTER TABLE `course` MODIFY COLUMN `address` VARCHAR(20) NOT NULL  COMMENT '课程地址';
        ALTER TABLE `student` MODIFY COLUMN `gender` VARCHAR(10) NOT NULL  COMMENT '学生性别';
        ALTER TABLE `student` MODIFY COLUMN `name` VARCHAR(20) NOT NULL  COMMENT '学生名称';
        ALTER TABLE `student` MODIFY COLUMN `classes_id` INT NOT NULL;
        ALTER TABLE `teacher` MODIFY COLUMN `name` VARCHAR(20) NOT NULL  COMMENT '教师名称';
        ALTER TABLE `course` ADD CONSTRAINT `fk_course_teacher_2de38fe7` FOREIGN KEY (`teacher_id`) REFERENCES `teacher` (`id`) ON DELETE CASCADE;"""


async def downgrade(db: BaseDBAsyncClient) -> str:
    return """
        ALTER TABLE `course` DROP FOREIGN KEY `fk_course_teacher_2de38fe7`;
        ALTER TABLE `course` DROP COLUMN `teacher_id`;
        ALTER TABLE `course` MODIFY COLUMN `name` VARCHAR(20) NOT NULL  COMMENT '课程名称';
        ALTER TABLE `course` MODIFY COLUMN `address` VARCHAR(20) NOT NULL  COMMENT '课程地址';
        ALTER TABLE `classes` MODIFY COLUMN `name` VARCHAR(20) NOT NULL  COMMENT '班级名称';
        ALTER TABLE `student` MODIFY COLUMN `gender` VARCHAR(10) NOT NULL  COMMENT '学生性别';
        ALTER TABLE `student` MODIFY COLUMN `name` VARCHAR(20) NOT NULL  COMMENT '学生名称';
        ALTER TABLE `student` MODIFY COLUMN `classes_id` INT NOT NULL;
        ALTER TABLE `teacher` MODIFY COLUMN `name` VARCHAR(20) NOT NULL  COMMENT '教师名称';"""
